﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Thingpower.SS.EduOnline.Model;
using Thingpower.SS.EduOnline.Provider;

namespace Thingpower.SS.EduOnline.WebAPI
{
    [RoutePrefix("eduonline/api/enrollments")]
    public class EnrollmentController : ApiController
    {
        [HttpGet, Route("")]
        public IHttpActionResult GetEnrollments([FromUri]int userId = 0, [FromUri]int courseId = 0)
        {
            return Ok(EnrollmentDAO.GetModels(userId, courseId));
        }

        [HttpPatch, Route("")]
        public IHttpActionResult PartiallyUpdateEnrollment([FromUri]int userId, [FromUri]int courseId, [FromBody]PatchEnrollmentInfo patchModel)
        {
            EnrollmentInfo _model = EnrollmentDAO.GetModel(userId, courseId);
            return Ok(patchModel.Status.ToString());
        }
    }
}
